package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceAssessment;
import com.ruoyi.service.service.IServiceAssessmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单评价表Controller
 * 
 * @author ZDL
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/service/assessment")
public class ServiceAssessmentController extends BaseController
{
    @Autowired
    private IServiceAssessmentService serviceAssessmentService;

    /**
     * 查询订单评价表列表
     */
    @PreAuthorize("@ss.hasPermi('service:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceAssessment serviceAssessment)
    {
        startPage();
        List<ServiceAssessment> list = serviceAssessmentService.selectServiceAssessmentList(serviceAssessment);
        return getDataTable(list);
    }

    /**
     * 导出订单评价表列表
     */
    @PreAuthorize("@ss.hasPermi('service:assessment:export')")
    @Log(title = "订单评价表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceAssessment serviceAssessment)
    {
        List<ServiceAssessment> list = serviceAssessmentService.selectServiceAssessmentList(serviceAssessment);
        ExcelUtil<ServiceAssessment> util = new ExcelUtil<ServiceAssessment>(ServiceAssessment.class);
        util.exportExcel(response, list, "订单评价表数据");
    }

    /**
     * 获取订单评价表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:assessment:query')")
    @GetMapping(value = "/{assessmentId}")
    public AjaxResult getInfo(@PathVariable("assessmentId") Long assessmentId)
    {
        return success(serviceAssessmentService.selectServiceAssessmentByAssessmentId(assessmentId));
    }

    /**
     * 新增订单评价表
     */
    @PreAuthorize("@ss.hasPermi('service:assessment:add')")
    @Log(title = "订单评价表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceAssessment serviceAssessment)
    {
        return toAjax(serviceAssessmentService.insertServiceAssessment(serviceAssessment));
    }

    /**
     * 修改订单评价表
     */
    @PreAuthorize("@ss.hasPermi('service:assessment:edit')")
    @Log(title = "订单评价表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceAssessment serviceAssessment)
    {
        return toAjax(serviceAssessmentService.updateServiceAssessment(serviceAssessment));
    }

    /**
     * 删除订单评价表
     */
    @PreAuthorize("@ss.hasPermi('service:assessment:remove')")
    @Log(title = "订单评价表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assessmentIds}")
    public AjaxResult remove(@PathVariable Long[] assessmentIds)
    {
        return toAjax(serviceAssessmentService.deleteServiceAssessmentByAssessmentIds(assessmentIds));
    }
}
